package org.thread.test04.demo04;

import org.thread.test03.way02.MyCallable;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author CSY
 * @date 2025 - 03 - 10
 */
public class Test01 {
    public static void main(String[] args) {

    }

    public static Integer test(Integer startNum,Integer endNum) {
        Integer sum = 0;
        Integer avg = endNum / 3;
        for (int i = 0; i < 3; i++) {
            MyCallable mc = new MyCallable();
            FutureTask ft = new FutureTask(mc);
            Thread t = new Thread(ft);
            t.start();
            try {
                sum += (int)ft.get();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return 0;
    }
}
